home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Demos / Tools / AppMaker / Examples / pre-built AMReminder / PowerPlant / CAMReminderApp.cp < prev    next >
Encoding:
Text File  |  1994-11-03  |  3.9 KB  |  175 lines  |  [TEXT/MMCC]

  1. // CAMReminderApp.cp -- application methods
  2. // Created 01/01/95 12:01 PM by AppMaker
  3.  
  4. #include "CAMReminderApp.h"
  5.  
  6. #include "CAMReminderDoc.h"
  7. #include "CMainWindow.h"
  8. #include "CAdd.h"
  9.  
  10. #include <UDesktop.h>
  11. #include <URegistrar.h>
  12. #include <UScreenPort.h>
  13. #include <PPobClasses.h>
  14. #include <PP_Messages.h>
  15.  
  16. // ---------------------------------------------------------------------------
  17. //        • CAMReminderApp
  18. // ---------------------------------------------------------------------------
  19. //    Default constructor
  20.  
  21. CAMReminderApp::CAMReminderApp()
  22.         :LDocApplication()
  23. {
  24.     UScreenPort::Initialize();
  25.  
  26.     RegisterClasses();
  27.  
  28.     SetUpMenus();
  29.  
  30.     // initialize app's data members:
  31. }
  32.  
  33.  
  34. // ---------------------------------------------------------------------------
  35. //        • ~CAMReminderApp
  36. // ---------------------------------------------------------------------------
  37. //    Destructor
  38. //
  39.  
  40. CAMReminderApp::~CAMReminderApp()
  41. {
  42. }
  43.  
  44. // ---------------------------------------------------------------------------
  45. //        • RegisterClasses
  46. // ---------------------------------------------------------------------------
  47. //
  48.  
  49. void
  50. CAMReminderApp::RegisterClasses()
  51. {
  52.     RegisterAllPPClasses();
  53.             // replace to register only classes that we use.
  54.             // windows know what classes they use
  55.             // so call static functions in each window/dialog,
  56.             // or generate a single function as union of all w/d's.
  57.  
  58.     // register custom pane classes
  59.     URegistrar::RegisterClass('Main', (ClassCreatorFunc)CMainWindow::CreateMainWindowStream);
  60.     URegistrar::RegisterClass('Add ', (ClassCreatorFunc)CAdd::CreateAddStream);
  61. }
  62.  
  63. // ---------------------------------------------------------------------------
  64. //        • SetUpMenus
  65. // ---------------------------------------------------------------------------
  66. //
  67.  
  68. void
  69. CAMReminderApp::SetUpMenus()
  70. {
  71.  
  72. }
  73.  
  74. // ---------------------------------------------------------------------------
  75. //        • StartUp
  76. // ---------------------------------------------------------------------------
  77. //    The application calls this member function automatically when the application
  78. //    is opened
  79.  
  80. void
  81. CAMReminderApp::StartUp()
  82. {
  83.     ObeyCommand(cmd_New, nil);
  84. }
  85.  
  86. //----------
  87. LModelObject*
  88. CAMReminderApp::MakeNewDocument()
  89. {
  90.     CAMReminderDoc    *theDoc = new CAMReminderDoc(this);
  91.  
  92.     return theDoc;
  93. }
  94.  
  95. //----------
  96. void
  97. CAMReminderApp::OpenDocument(
  98.     FSSpec    *inMacFSSpec)
  99. {
  100.     CAMReminderDoc    *theDoc = new CAMReminderDoc(this, inMacFSSpec);
  101. }
  102.  
  103. //----------
  104. void
  105. CAMReminderApp::ChooseDocument()
  106. {
  107.     SFTypeList            typeList;
  108.     short                numTypes;
  109.     StandardFileReply    macFileReply;
  110.  
  111.     typeList[0] = 'TEXT';
  112.     numTypes = 1;
  113.  
  114.     UDesktop::Deactivate();
  115.     ::StandardGetFile(nil, numTypes, typeList, &macFileReply);
  116.     UDesktop::Activate();
  117.  
  118.     if (macFileReply.sfGood) {
  119.         OpenDocument(&macFileReply.sfFile);
  120.     }
  121. }
  122.  
  123. // ---------------------------------------------------------------------------
  124. //        • ObeyCommand
  125. // ---------------------------------------------------------------------------
  126. //    Respond to commands
  127.  
  128. Boolean
  129. CAMReminderApp::ObeyCommand(
  130.     CommandT    inCommand,
  131.     void        *ioParam)
  132. {
  133.     Boolean    cmdHandled = true;
  134.  
  135.     switch (inCommand) {
  136.  
  137.     // +++ Add cases here for the commands you handle
  138.     //        Remember to add same cases to FindCommandStatus below
  139.     //        to enable/disable the menu items for the commands
  140.  
  141.     default:
  142.             cmdHandled = LDocApplication::ObeyCommand(inCommand, ioParam);
  143.         break;
  144.     }
  145.  
  146.     return cmdHandled;
  147. }
  148.  
  149.  
  150. // ---------------------------------------------------------------------------
  151. //        • FindCommandStatus
  152. // ---------------------------------------------------------------------------
  153. //    Pass back status of a (menu) command
  154.  
  155. void
  156. CAMReminderApp::FindCommandStatus(
  157.     CommandT    inCommand,
  158.     Boolean        &outEnabled,
  159.     Boolean        &outUsesMark,
  160.     Char16        &outMark,
  161.     Str255        outName)
  162. {
  163.     outUsesMark = false;
  164.  
  165.     switch (inCommand) {
  166.  
  167.     // +++ Add cases here for the commands you handle
  168.  
  169.     default:
  170.             LDocApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
  171.                                                 outMark, outName);
  172.         break;
  173.     }
  174. }
  175.